package com.lpwa.web.core.config;

import com.lpwa.common.utils.RedisUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;
import java.util.Date;
import java.util.Iterator;
import java.util.Set;

@Component
public class MyStartupRunner implements CommandLineRunner {

    @Autowired
    private RedisUtil redisUtil;
    @Autowired
    private RedisTemplate<String, Object> redisTemplate;

    @Override
    public void run(String... strings) throws Exception {

        redisUtil.del("locatorMacs");
        System.out.println(new Date());

        Set<String> keys = redisTemplate.keys("*");
        Iterator<String> it1 = keys.iterator();
        while (it1.hasNext()) {
            redisTemplate.delete(it1.next());
        }
    }
}